<?php
	$table = "product";

	$pageSize = 40;
	$pageNum  = 1;
	if (isset($_GET['pageNum']) == true)
		$pageNum = $_GET['pageNum'];
	else
		$pageNum = 1;
	$startRow  = ($pageNum - 1) * $pageSize;
	$endRow    = $startRow + $pageSize;
	$totalRows = $conn->get_maxrow_of_table($table);

	$list_record = $conn->get_all_data($table, -1, 1, $option1, $option2 = ' LIMIT ' . $startRow . ',' . $pageSize . '');
?>
<a href="index.php?p=<?=$table ?>&t=add" class="pull-right btn btn-success">Add Product</a>
<div class="page-header" xmlns="http://www.w3.org/1999/html">
    <h1>Product Manager</h1>
</div>
<div class="tabbable">
    <ul class="nav nav-tabs">
        <li class="active"><a data-toggle="tab" href="#tab1">Product List</a></li>
        <li><a data-toggle="tab" href="#tab2">Search</a></li>
    </ul>
    <div class="tab-content">
        <div id="tab1" class="tab-pane active">
            <form class="form-inline" method="post" action="">
                <table class="table table-bordered">
                    <thead>
                    <tr>
                        <th>#</th>
                        <th>Tên trang</th>
                        <th>Mô tả</th>
                        <th>Công cụ</th>
                    </tr>
                    </thead>
                    <tbody>
					<?php
						foreach ($list_record as $k => $value) {
							?>
                        <tr>
                            <td><?=$k + 1?></td>
                            <td><?=$value['title']  ?></td>
                            <td><?=$value['description']  ?></td>
                            <td width="115">
                                <a class="btn btn-mini" rel="tooltip" data-original-title="Sửa"
                                   href="index.php?p=<?=$table ?>&t=edit&id=<?=$value['id'] ?>" title="Sửa">
                                    <i class="icon-edit"></i> Edit</a>
                                </a>
                                <a class="btn btn-mini btn-danger" rel="tooltip" data-original-title="Xóa" href="javascript:void(0)"
                                   onclick="if (confirm('Are you sure ?')) dashboard.admin.delete_record('<?php echo $table; ?>','<?php echo $value['id']; ?>');"
                                   title="Xóa">
                                    <i class="icon-remove icon-white"></i> Delete
                                </a>
                            </td>
                        </tr>
							<? } ?>
                    </tbody>
                    <tfoot>
                    <tr>
                        <td colspan="9">
                            <div class="pagination">
                                <ul class="pull-right">
			                        <?php echo $conn->pageList($totalRows, $pageNum, $pageSize); ?>
                                </ul>
                            </div>
                            <!-- End .pagination -->
                            <div class="bulk-actions align-left">
                                <select name="fbulkaction">
                                    <option value="">Select action...</option>
                                    <option onclick="dashboard.admin.action.deleteAll('<?=$table  ?>')" value="delete">
                                        Delete
                                    </option>
                                </select>
                                <input type="submit" value="Process" class="btn" name="fsubmitbulk">
                            </div>
                            <div class="clear"></div>
                        </td>
                    </tr>
                    </tfoot>
                </table
            </form>
        </div>
    </div>
</div>
